package ais.dcproject.action;

import ais.dcproject.model.User;
import ais.dcproject.service.LoginService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{
	
	private User user;
	
	private LoginService loginService;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}

	public String execute() throws Exception {
		User user = loginService.validateLogin(getUser().getStuNum(), getUser().getIdCard());
		if(null == user){
			return INPUT;
		}
		ActionContext.getContext().getSession().put("user", user);;
		return SUCCESS;
	}

}
